﻿namespace Blaze.Utilities
{
    using AppImplements;

    /// <summary>
    /// 应用相关的常用功能。
    /// </summary>
    public static class AppUtility
    {
        /// <summary>
        /// 获取或设置<see cref="IAppUtility"/>的具体实现。
        /// </summary>
        public static IAppUtility Implement
        {
            get
            {
#if UNITY_EDITOR
                mImplement = new EditorImplement();
#elif UNITY_STANDALONE_WIN
                mImplement = new WindowsImplement();
#elif UNITY_ANDROID
                mImplement = new AndroidImplement();
#elif UNITY_IOS
                mImplement = new IOSImplement();
#endif
                return mImplement;
            }
        }

        /// <summary>
        /// 安装指定的安装包。
        /// </summary>
        /// <param name="file">游戏包文件</param>
        public static void Install(string file)
        {
            Implement.Install(file);
        }

        /// <summary>
        /// 获取一个值，表示指定的应用是否已经安装。
        /// </summary>
        /// <param name="bundleId">包名</param>
        public static bool IsInstalled(string bundleId)
        {
            return Implement.IsInstalled(bundleId);
        }

        /// <summary>
        /// 打开外部链接地址。
        /// </summary>
        /// <param name="url">地址</param>
        public static void OpenUrl(string url)
        {
            Implement.OpenUrl(url);
        }

        /// <summary>
        /// 启动指定包名的应用。
        /// </summary>
        /// <param name="bundleId">包名</param>
        public static void Start(string bundleId)
        {
            Implement.Start(bundleId);
        }

        private static IAppUtility mImplement;
    }
}